<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>Makes "field" required and 13 or larger.</title>
    <link rel="stylesheet" href="https://jqueryvalidation.org/files/demo/site-demos.css">

</head>

<body>
    <form id="myform">
        <label for="field">Required, minimum 0: </label>
        <input type="text" class="left" id="field" data-rule-decimalNumber="true" name="field">
        <br />
        <input type="submit" value="Validate!">
    </form>
    <script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
    <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
    <script>
        $(function () {
            $.validator.addMethod("decimalNumber", function (value, element, params) {
                return this.optional(element) || /^\d+[.]?\d+$/.test(value);
            }, "正整数或者小数.");

            // just for the demos, avoids form submit
            jQuery.validator.setDefaults({
                debug: true,
                success: "valid"
            });
            $("#myform").validate();
            // $("#myform").validate({
            //     rules:{
            //         field:{
            //           decimalNumber:true  
            //         }
                    
            //     }
            // });
        });
    </script>
</body>

</html>
